using Common.Commands;
using Common.Commands.LeadCommands;
using Core.Domain.Model;
using Dto.ApiResponses.LeadResponses;
using Sanelib.DataOperation;

namespace Core.Processors.LeadsProcessors
{
    public class AddAnonymousLeadProcessor : ICommandProcessor<AddAnonymousLead>
    {
        private readonly IRepository<Lead> _leadsRepository;

        public AddAnonymousLeadProcessor(IRepository<Lead> leadsRepository)
        {
            _leadsRepository = leadsRepository;
        }

        public dynamic Process(AddAnonymousLead command)
        {
            var leads = new Lead
            {
                Id = command.Id,
                Name = command.Name,
                CompanyName = command.CompanyName,
                Email = command.Email,
                Phone = command.Phone,
                Description = command.Description,                                
            };
            _leadsRepository.Add(leads);

            var response = new LeadResponse
            {
                Id = command.Id,
                Name = command.Name,
                CompanyName = command.CompanyName,
                Email = command.Email,
                Phone = command.Phone,
                Description = command.Description                
            };

            return response;
        }
    }
}